﻿using System.ComponentModel;
using System.Windows;

namespace Gmantis.Controls.Chart
{
    [EditorBrowsable(EditorBrowsableState.Advanced)]
    public enum Clipping
    {
        Auto,
        System,
        Custom
    }

    public class LineAreaOptions : DependencyObject
    {
        // Fields
        public static DependencyProperty ClippingProperty = Utils.RegisterAttachedProperty("Clipping", typeof(Clipping), typeof(LineAreaOptions), new PropertyChangedCallback(Chart.OnAttachedPropertyChanged), Clipping.Auto);
        public static DependencyProperty OptimizationRadiusProperty = Utils.RegisterAttachedProperty("OptimizationRadius", typeof(double), typeof(LineAreaOptions), new PropertyChangedCallback(Chart.OnAttachedPropertyChanged), (double)1.0 / (double)0.0);
        public static readonly DependencyProperty OptimizationRadiusScopeProperty = DependencyProperty.RegisterAttached("OptimizationRadiusScope", typeof(OptimizationRadiusScope), typeof(LineAreaOptions), new PropertyMetadata(OptimizationRadiusScope.Lines));

        // Methods
        [AttachedPropertyBrowsableForType(typeof(Chart)), EditorBrowsable(EditorBrowsableState.Advanced)]
        public static Clipping GetClipping(Chart chart)
        {
            return (Clipping)chart.GetValue(ClippingProperty);
        }

        [EditorBrowsable(EditorBrowsableState.Advanced), AttachedPropertyBrowsableForType(typeof(Chart))]
        public static double GetOptimizationRadius(DependencyObject chart)
        {
            return (double)chart.GetValue(OptimizationRadiusProperty);
        }

        [EditorBrowsable(EditorBrowsableState.Advanced), AttachedPropertyBrowsableForType(typeof(Chart))]
        public static OptimizationRadiusScope GetOptimizationRadiusScope(Chart chart)
        {
            return (OptimizationRadiusScope)chart.GetValue(OptimizationRadiusScopeProperty);
        }

        internal static void Reset(Chart chart)
        {
            chart.ClearValue(ClippingProperty);
            chart.ClearValue(OptimizationRadiusProperty);
            chart.ClearValue(OptimizationRadiusScopeProperty);
        }

        public static void SetClipping(Chart chart, Clipping value)
        {
            chart.SetValue(ClippingProperty, value);
        }

        public static void SetOptimizationRadius(DependencyObject chart, double value)
        {
            chart.SetValue(OptimizationRadiusProperty, value);
        }

        public static void SetOptimizationRadiusScope(DependencyObject obj, OptimizationRadiusScope value)
        {
            obj.SetValue(OptimizationRadiusScopeProperty, value);
        }
    }
}
